<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- echarts的容器，高度是必写的, 宽度可选 -->
    <div id="main" style="height: 400px"></div>

    <script src="../libs/echarts-5.3.3.js"></script>
    <script>
      window.onload = function () {
        // 1.基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'))

        // 2.指定图表的配置项和数据
        var option = {
          backgroundColor: 'rgba(40,46,72)',
          grid: {
            show: true,
            left: '5%',
            right: '6%',
            top: '30%',
            bottom: '5%',
            containLabel: true,
          },
          xAxis: {
            name: '月份',
            data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月'],
            axisLabel: {
              color: 'white',
            },
            axisLine: {
              show: true,
              lineStyle: {
                color: '#42A4Ff',
              },
            },
            axisTick: {
              show: false,
            },
          },
          yAxis: {
            name: '↑',
            nameTextStyle: {
              color: 'white',
              fontSize: 12,
            },
            axisLine: {
              show: true,
              lineStyle: {
                color: '#42A4ff',
              },
              axisTick: {
                show: false,
              },
              splitLine: {
                show: true,
                lineStyle: {
                  color: '#42a4ff',
                },
              },
              axisLabel: {
                color: 'white',
              },
            },
          },

          series: [
            {
              name: '销量',
              type: 'bar',
              barWidth: 27,
              itemStyle: {
                color: {
                  type: 'linear',
                  x: 0,
                  y: 0,
                  x2: 0,
                  y2: 1,
                  colorStops: [
                    {
                      offset: 0,
                      color: '#0181ff',
                    },
                    {
                      offset: 1,
                      color: '#033bff',
                    },
                  ],
                },
              },
              data: [500, 2000, 3600, 1000, 1000, 2000, 4000],
            },
          ],
        }

        // 3.使用刚指定的配置项和数据显示图表。
        myChart.setOption(option)
      }
    </script>
  </body>
</html>
